<template>
  <div id="controlBank">
    <div class="homeTitle">行社交易管控设置</div>
    <div class="titleName">债券交易</div>
    <table>
      <tr>
        <td>基本管控设置</td>
        <td><span>*</span>部门经理审批限额(万元)(含填写值)</td>
        <td><span>*</span>分管领导审批限额(万元)(含填写值)</td>
        <td><span>*</span>行长审批限额(万元)(含填写值)</td>
        <!-- <td><span>*</span>理事长审批限额(万元)(含填写值</td> -->
      </tr>
      <tr>
        <td>审核金额控制</td>
        <td><el-input v-model="basic.manager" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="basic.leader" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="basic.president" placeholder="请输入" size="small"></el-input></td>
        <!-- <td><el-input v-model="basic.chairman" placeholder="请输入" size="small"></el-input></td> -->
      </tr>
    </table>
    
    <table>
      <tr>
        <td>风险管控设置</td>
        <td>交易限制值(含填写值)</td>
        <td>省联社授权值(含填写值)</td>
        <td>预警提醒值(含填写值)</td>
      </tr>
      <tr>
        <td>{{jzData.item}}（行社内）</td>
        <td><el-input v-model="jzData.restrictions" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="jzData.authorization" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="jzData.warning" placeholder="请输入百分比" size="small"></el-input></td>
      </tr>
      <tr>
        <td>{{xyData.item}}</td>
        <td><el-input v-model="xyData.restrictions" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="xyData.authorization" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="xyData.warning" placeholder="请输入百分比" size="small"></el-input></td>
      </tr>
   
    </table>
    <div class="titleName">债券回购交易</div>
    <table>
      <tr>
        <td>基本管控设置</td>
        <td><span>*</span>部门经理审批限额(万元)(含填写值)</td>
        <td><span>*</span>分管领导审批限额(万元)(含填写值)</td>
        <td><span>*</span>行长审批限额(万元)(含填写值)</td>
        <!-- <td><span>*</span>理事长审批限额(万元)(含填写值)</td> -->
      </tr>
      <tr>
        <td>审核金额控制</td>
        <td><el-input v-model="zqhg.manager" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="zqhg.leader" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="zqhg.president" placeholder="请输入" size="small"></el-input></td>
      </tr>
    </table>
    <table>
      <tr>
        <td>风险管控设置</td>
        <td>交易限制值(含填写值)</td>
        <td>省联社授权值(含填写值)</td>
        <td>预警提醒值(含填写值)</td>
      </tr>
       <tr>
        <td>{{hgData.item}}（行社内）</td>
        <td><el-input v-model="hgData.restrictions" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="hgData.authorization" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="hgData.warning" placeholder="请输入百分比" size="small"></el-input></td>
      </tr>
      <tr>
        <td>{{yhData.item}}</td>
        <td><el-input v-model="yhData.restrictions" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="yhData.authorization" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="yhData.warning" placeholder="请输入百分比" size="small"></el-input></td>
      </tr>
    </table>
     <div class="titleName">同业拆借交易</div>
    <table>
      <tr>
        <td>基本管控设置</td>
        <td><span>*</span>部门经理审批限额(万元)(含填写值)</td>
        <td><span>*</span>分管领导审批限额(万元)(含填写值)</td>
        <td><span>*</span>行长审批限额(万元)(含填写值)</td>
        <!-- <td><span>*</span>理事长审批限额(万元)(含填写值)</td> -->
      </tr>
      <tr>
        <td>审核金额控制</td>
        <td><el-input v-model="chai.manager" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="chai.leader" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="chai.president" placeholder="请输入" size="small"></el-input></td>
      </tr>
    </table>
    <table>
      <tr>
        <td>风险管控设置</td>
        <td>交易限制值(含填写值)</td>
        <td>省联社授权值(含填写值)</td>
        <td>预警提醒值(含填写值)</td>
      </tr>
     
      <tr>
        <td>（与同业存单、存放	同业合并控制）{{jzData2.item}}</td>
        <td><el-input v-model="jzData2.restrictions" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="jzData2.authorization" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="jzData2.warning" placeholder="请输入百分比" size="small"></el-input></td>
      </tr>
    </table>
    <div class="titleName">同业存单交易</div>
    <table>
      <tr>
        <td>基本管控设置</td>
        <td><span>*</span>部门经理审批限额(万元)(含填写值)</td>
        <td><span>*</span>分管领导审批限额(万元)(含填写值)</td>
        <td><span>*</span>行长审批限额(万元)(含填写值)</td>
        <!-- <td><span>*</span>理事长审批限额(万元)(含填写值)</td> -->
      </tr>
      <tr>
        <td>审核金额控制</td>
        <td><el-input v-model="tycd.manager" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="tycd.leader" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="tycd.president" placeholder="请输入" size="small"></el-input></td>
        <!-- <td><el-input v-model="tel" placeholder="请输入" size="small"></el-input></td> -->
      </tr>
    </table>
    <div class="titleName">存放同业交易</div>
    <table>
      <tr>
        <td>基本管控设置</td>
        <td><span>*</span>部门经理审批限额(万元)(含填写值)</td>
        <td><span>*</span>分管领导审批限额(万元)(含填写值)</td>
        <td><span>*</span>行长审批限额(万元)(含填写值)</td>
        <!-- <td><span>*</span>理事长审批限额(万元)(含填写值)</td> -->
      </tr>
      <tr>
        <td>审核金额控制</td>
        <td><el-input v-model="cfty.manager" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="cfty.leader" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="cfty.president" placeholder="请输入" size="small"></el-input></td>
        <!-- <td><el-input v-model="tel" placeholder="请输入" size="small"></el-input></td> -->
      </tr>
    </table>
    <div class="titleName">债券借贷交易</div>
    <table>
      <tr>
        <td>基本管控设置</td>
        <td><span>*</span>部门经理审批限额(万元)(含填写值)</td>
        <td><span>*</span>分管领导审批限额(万元)(含填写值)</td>
        <td><span>*</span>行长审批限额(万元)(含填写值)</td>
        <!-- <td><span>*</span>理事长审批限额(万元)(含填写值)</td> -->
      </tr>
      <tr>
        <td>审核金额控制</td>
        <td><el-input v-model="zqjd.manager" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="zqjd.leader" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="zqjd.president" placeholder="请输入" size="small"></el-input></td>
        <!-- <td><el-input v-model="tel" placeholder="请输入" size="small"></el-input></td> -->
      </tr>
    </table>
    <!-- <table>
      <tr>
        <td>风险管控设置</td>
        <td>交易限制值(含填写值)</td>
        <td>省联社授权值(含填写值)</td>
        <td>预警提醒值(含填写值)</td>
      </tr>

        <tr>
        <td>{{zqData.item}}（行社内）</td>
        <td><el-input v-model="zqData.restrictions" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="zqData.authorization" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="zqData.warning" placeholder="请输入百分比" size="small"></el-input></td>
      </tr>
    </table> -->
    <div class="titleName">理财产品交易</div>
    <table>
      <tr>
        <td>基本管控设置</td>
        <td><span>*</span>部门经理审批限额(万元)(含填写值)</td>
        <td><span>*</span>分管领导审批限额(万元)(含填写值)</td>
        <td><span>*</span>行长审批限额(万元)(含填写值)</td>
        <!-- <td><span>*</span>理事长审批限额(万元)(含填写值)</td> -->
      </tr>
      <tr>
        <td>审核金额控制</td>
        <td><el-input v-model="lccp.manager" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="lccp.leader" placeholder="请输入" size="small"></el-input></td>
        <td><el-input v-model="lccp.president" placeholder="请输入" size="small"></el-input></td>
        <!-- <td><el-input v-model="tel" placeholder="请输入" size="small"></el-input></td> -->
      </tr>
    </table>
    <table>
      <tr>
        <td>风险管控设置</td>
        <td>交易限制值(含填写值)</td>
        <td>省联社授权值(含填写值)</td>
        <td>预警提醒值(含填写值)</td>
      </tr>
       <tr>
        <td>{{jyData.item}}（行社内）</td>
        <td><el-input v-model="jyData.restrictions" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="jyData.authorization" placeholder="请输入百分比" size="small"></el-input></td>
        <td><el-input v-model="jyData.warning" placeholder="请输入百分比" size="small"></el-input></td>
      </tr>
    
    </table>
    <div class="btn">
      <el-button type="primary" size="small" @click="addSettings">提交</el-button>
      <el-button type="primary" size="small">取消</el-button>
    </div>
  </div>
</template>

<script>
export default {
  name: 'controlBank',
  data () {
    return {
      tel:'',
      xyData: {
        item: '信用债与利率债比例'
      },
      jzData: {
        item: '信用债集中度'
      },
      jyData: {
        item: '交易集中度'
      },
      jzData2: {
        item: '交易集中度'
      },
      zqData: {
        item: '单一客户集中度'
      },
      hgData: {
        item: '单一客户集中度'
      },
      yhData: {
        item: '非银与银行对手交易比例'
      },
      basic:{
        model: '债券交易',
        examineMoney: 999999999999,
        chairman: 999999999999
      },
      
      tycd: {
        model: '同业存单交易',
        examineMoney: 999999999999,
        chairman: 999999999999  
      },
      chai: {
        model: '同业拆借交易',
        examineMoney: 999999999999,
        chairman: 999999999999  
      },
      lccp: {
        model: '理财产品交易',
        examineMoney: 999999999999,
        chairman: 999999999999
      },
      zqjd: {
        model: '债券借贷交易',
        examineMoney: 999999999999,
        chairman: 999999999999
      },
      cfty: {
        model: '存放同业交易',
        examineMoney: 999999999999,
        chairman: 999999999999
      },
      zqhg: {
        model: '债券回购交易',
        examineMoney: 999999999999,
        chairman: 999999999999
      }
    };
  },
  methods: {
    addSettings() {
      let riskJson = []
      let basicJson = []
      let lccpJson = []
      //riskJson.push('1', '2')
      this.xyData.model = '债券交易'
      this.jzData.model = '债券交易'
      this.jyData.model = '理财产品交易'
      this.jzData2.model = '同业相关'
     // this.zqData.model = '债券借贷交易'
      this.hgData.model = '债券回购交易'
      this.yhData.model = '债券回购交易'
      if(this.xyData.restrictions != '') {
        
          riskJson.push(this.xyData)
      }
      if(this.jzData.restrictions != '') {
          riskJson.push(this.jzData)
      }
      if(this.jyData.restrictions != '') {
          riskJson.push(this.jyData)
      }
       if(this.jzData2.restrictions != '') {
          riskJson.push(this.jzData2)
      }
      // if(this.zqData.restrictions != '') {
      //   riskJson.push(this.zqData)
      // }
      if(this.hgData.restrictions != '') {
        riskJson.push(this.hgData)
      }
      if(this.yhData.restrictions != '') {
        riskJson.push(this.yhData)
      }
      //riskJson.push(this.jyData)
      if(this.basic.manager != '' && this.basic.manager != undefined) {
          basicJson.push(this.basic)
      }
      if(this.chai.manager != ''  && this.chai.manager != undefined) {
          basicJson.push(this.chai)
      }
      if(this.lccp.manager != ''  && this.lccp.manager != undefined) {
          basicJson.push(this.lccp)
      }
      if(this.cfty.manager != ''  && this.cfty.manager != undefined) {
          basicJson.push(this.cfty)
      }
      if(this.zqjd.manager != ''  && this.zqjd.manager != undefined) {
          basicJson.push(this.zqjd)
      }
      if(this.zqhg.manager != ''  && this.zqhg.manager != undefined) {
          basicJson.push(this.zqhg)
      }
      if(this.tycd.manager != ''  && this.tycd.manager != undefined) {
          basicJson.push(this.tycd)
      }
    //  basicJson.push(this.lccp)
    if(basicJson.length > 0) {
    
      let param = {
        basicJson: JSON.stringify(basicJson),
        riskJson: JSON.stringify(riskJson)
      }
      console.log(param)
      this.axios.post('bondFlowBasic/addOrUpdate', param).then((res) => {
        this.$message({
          type:'success',
          message: '添加成功'
        })
        this.getDetail()
      })
        
    } else {
      this.$message({
        type: 'warning',
        message: '请填写完整信息'
      })
    }
    },
    getDetail() {
      this.axios.get('bondFlowBasic/selectRiskList').then(res => {
          let data = res.data.data
          data.forEach((item, index) => {
              if(item.model == '债券交易'){
                let riskList = item.riskList
                riskList.forEach(item => {
                  if(item.item == '信用债与利率债比例') {
                    this.xyData = item
                  }
                  if(item.item == '信用债集中度') {
                    this.jzData = item
                  }
                })
              }
              if(item.model == '债券回购交易'){
                let riskList = item.riskList
                riskList.forEach(item => {
                  if(item.item == '单一客户集中度') {
                    this.hgData = item
                  }
                  if(item.item == '非银与银行对手交易比例') {
                    this.yhData = item
                  }
                })
              }
              
              if(item.model == '同业相关'){
                let riskList = item.riskList
                riskList.forEach(item => {
                  if(item.item == '交易集中度') {
                    this.jzData2 = item
                  }
                })
              }

              if(item.model == '债券借贷交易'){
                let riskList = item.riskList
                riskList.forEach(item => {
                  if(item.item == '单一客户集中度') {
                    this.zqData = item
                  }
                })
              }
              if(item.model == '理财产品交易'){
                let riskList = item.riskList
                riskList.forEach(item => {
                  if(item.item == '交易集中度') {
                    this.jyData = item
                  }
                })
              }
          })
      })

      this.axios.get('bondFlowBasic/selectBasicList').then(res => {
        let data = res.data.data
            data.forEach((item, index) => {
              switch(item.model) {
                case '债券交易':
                    this.basic = item.basicList[0];
                    this.basic.model = '债券交易';break;
                    
                case '债券回购交易':
                    this.zqhg = item.basicList[0];
                    this.zqhg.model = '债券回购交易';break;
                case '同业存单交易':
                    this.tycd = item.basicList[0];
                    this.tycd.model = '同业存单交易';break;
                case '同业拆借交易':
                    this.chai = item.basicList[0];
                    this.chai.model = '同业拆借交易';break;
                case '理财产品交易':
                    this.lccp = item.basicList[0];
                    this.lccp.model = '理财产品交易';break;
                case '债券借贷交易':
                    this.zqjd = item.basicList[0];
                    this.zqjd.model = '债券借贷交易';break;
                case '存放同业交易':
                    this.cfty = item.basicList[0];
                    this.cfty.model = '存放同业交易';break;
                default: break;
              }
     
              console.log(this.basic)
          })
      })
    }
  },
  mounted() {
    let riskJson = []
      riskJson.push('1', '2')
      console.log(riskJson)
      this.getDetail()  
  }

};
</script>

<style lang="scss">
  #controlBank {
    padding-bottom: 20px;
    .titleName {
      height: 50px;
      background: white;
      padding-left: 20px;
      line-height: 50px;
      margin-top: 20px;
    }
    table {
      margin: 15px 0;
      width: 100%;
      tr {
        &:first-child {
         td {
           background-color: rgba(58, 58, 58, 0.4);
           color: white;
           padding: 10px 15px;
           text-align: center;
           span {
             color: red;
           }
         } 
        }
        td {
          background-color: rgba(58, 58, 58, 0.3);
          padding: 10px 10px;
          text-align: center;
          color: white;
          .el-input__inner{
            background: transparent;
            color:white;
            border: 0
          }
        }
      }
    }
    .btn {
      margin-top: 20px;
      text-align: center;
      .el-button {
        margin-right: 20px;
      }
    }
  }
</style>

